package com.itcpay.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * IOC容器与bean的获取
 * @author liufeng
 * @date 2017-6-11
 */
public class App 
{
    public static void main( String[] args )
    {
    	//获取容器对象
    	ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:application-context.xml");
    	/**
    	 * 获取bean的三种常用方法
    	 * 1、
    	 * 2、
    	 * 3、
    	 */
    	Dog dog1 = (Dog) ac.getBean("dog");
    	Dog dog2 = ac.getBean(Dog.class);
    	Dog dog3 = ac.getBean("dog", Dog.class);
        System.out.println( "dog1:" + dog1 );
        System.out.println( "dog2:" + dog2 );
        System.out.println( "dog3:" + dog3 );
        
        /**
         * 输出一下信息
         * 创建Dog
         * dog1:com.itcpay.spring.Dog@61dc03ce
         * dog2:com.itcpay.spring.Dog@61dc03ce
         * dog3:com.itcpay.spring.Dog@61dc03ce
         */
    }
}
